package nowcoder.hw.hj27;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String s = reader.readLine();
        String[] strs = s.split(" ");
        int n = Integer.valueOf(strs[0]);
        int k = Integer.valueOf(strs[strs.length - 1]);
        String word = strs[strs.length - 2];
        Map<Character,Integer> map =new HashMap<>();
        List<String> bros = new ArrayList<>();
        for (int i = 0; i < word.length(); i++) {
            map.put(word.charAt(i), map.getOrDefault(word.charAt(i),0)+1);
        }
        for (int i = 1; i <=n; i++) {
            if (isBro(strs[i], word, map)) {
                bros.add(strs[i]);
            }
        }
        System.out.println(bros.size());
        if (k<=bros.size()){
            Collections.sort(bros);
            System.out.println(bros.get(k-1));
        }

    }

    private static boolean isBro(String str, String word, Map<Character, Integer> map) {
        if (str.length() != word.length()) return false;
        boolean eq = true;
        Map<Character, Integer> map2 = new HashMap<>();
        for (int i = 0; i < word.length(); i++) {
            map2.put(str.charAt(i), map2.getOrDefault(str.charAt(i), 0)+1);
            if (str.charAt(i) == word.charAt(i)) {
                continue;
            } else if (!map.containsKey(str.charAt(i))) {
                //包含比Word多的字符，
                return false;
            } else eq = false;
        }
        //同一个单词
        if (eq) return false;
        //两个单词字符不一样多
        if (map.size() != map2.size()) return false;
        //这里，说明str的字符都在Word里，但是Word里的在str?
        for (Map.Entry<Character, Integer> entry :
                map.entrySet()) {
            if (!entry.getValue().equals(map2.get(entry.getKey()))) {
                //每个字符的个数不同
                return false;
            }
        }
//        System.out.println(String.format("%s:%s:%b", str, word, true));
        return true;
    }
}
